import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import postCssPxToRem from 'postcss-pxtorem'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 37.5,
          propList: ['*'],
          selectorBlackList: ['html'],
          minPixelValue: 2,
          exclude: [/node_modules/],
        })
      ]
    }
  },
  server: {
    host: '0.0.0.0',
    proxy: {
      '/api': {
        target: 'https://m.weibo.cn',
        changeOrigin: true
      },
      '/statuses': {
        target: 'https://m.weibo.cn',
        changeOrigin: true
      },
      '/comments': {
        target: 'https://m.weibo.cn',
        changeOrigin: true
      },
      '/f.video': {
        target: 'https://m.weibo.cn',
        changeOrigin: true
      },
      '/o0': {
        target: 'https://m.weibo.cn',
        changeOrigin: true
      },
      '/attitudes': {
        target: 'https://m.weibo.cn',
        changeOrigin: true
      },
      /* '/detail': {
        target: 'https://m.weibo.cn',
        changeOrigin: true
      } */
    }
  }
})
